package com.tvunetworks.center.user.config.web;

import com.tvunetworks.center.common.util.ResultUtil;
import org.springframework.boot.web.servlet.error.DefaultErrorAttributes;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.WebRequest;

import java.util.HashMap;
import java.util.Map;

/**
 * @program:
 * @description:
 * @author HenryChen
 * @create: 10/17/2019 6:09 PM
 **/
@Component
public class CustomerErrorAttributes extends DefaultErrorAttributes {

    @Override
    public Map<String, Object> getErrorAttributes(WebRequest webRequest, boolean includeStackTrace) {
        Map<String,Object> map  = super.getErrorAttributes(webRequest, includeStackTrace);
        Map<String, Object> result = new HashMap<>();
        result.put("errorCode" , ResultUtil.CLIENT_ERROR);
        result.put("errorInfo" , map.get("message"));
        result.put("result" , null);
        return result;
    }
}